﻿/************************************************
 * Copyright (C) 2011 东北农业大学(NEAU)
 * 版权所有。
 * 文件名：CommunityDetail.aspx.cs
 * 版本号：v1.0
 * 文件功能描述：职工社区的详细信息
 * 作者：侯建
 * 创建日期：2011.04.06
************************************************/
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jxym.DBUtility;
using System.Data.SqlClient;

namespace Jxym.wlkc2011.Module.Default.server.Community
{
    public partial class CommunityDetail : System.Web.UI.Page
    {
        MsSqlDal<model.Community> com = new MsSqlDal<model.Community>();
        //MsSqlDal<model.Community> com = new MsSqlDal<model.Community>();
        SqlParameter[] values = new SqlParameter[] { };
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["id2"] != null)
            {
                int ID = Convert.ToInt32(Request.Params["id2"]);
                model.Community comModel = com.GetModel("ID=" + ID, values);
                this.lblTitle.Text = comModel.Title;
                this.lblAddUser.Text = MyGet.GetUserInfoByID(comModel.AddUser).Name;
                this.lblAddTime.Text = comModel.AddTime.ToString();
                this.lblContent.Text = comModel.ContentText;
                this.lblqwe.Text = MyGet.GetDeptInfoByID(MyGet.GetUserInfoByID(comModel.AddUser).DepartmentID).Name;
                ReplyData();
            }
        }

        //留言回复绑定
        public void ReplyData() 
        {
            this.ReplyRepeater.DataSource = com.GetList("CommunityType = 1 and PrantID = " + Convert.ToInt32(Request.Params["id2"]), null, "", 0);
            this.ReplyRepeater.DataBind();
        }

        //回复按钮
        protected void butReply_Click(object sender, EventArgs e)
        {
            int CommunityType = 1;
            int ClassID = 1;
            SqlParameter[] values = new SqlParameter[] 
            {
                new SqlParameter("@ContentText",this.txtReply.Text),
                new SqlParameter("@AddTime",DateTime.Now),
                new SqlParameter("@AddUser",Jxym.Common.Request.AdminID("user")),
                new SqlParameter("@CommunityType",CommunityType),
                new SqlParameter("@ClassID",ClassID),
                new SqlParameter("@PrantID",Convert.ToInt32(Request.Params["id2"]))
            };
            int add = Convert.ToInt32(com.Add(values));
            if (add > 0)
            {
                this.txtReply.Text = "";
                ReplyData();
            }
        }
    }
}